home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Speech Synthesis Manager / Installer Source / ActionAtoms / SetFolderIconAA.c < prev   
Encoding:
C/C++ Source or Header  |  1996-11-11  |  2.3 KB  |  82 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *    File:        SetFolderIconAA.c -    C Source
  4.  *
  5.  *    Author:        Deric Horn
  6.  *
  7.  *    Action atom to set the custom icon finder flag of the parent folder of the 
  8.  *    specified file, infs.  It also clears the init'd bit so the finder knows
  9.  *    to update the desktop/display information.
  10.  *
  11.  *    History:    <1>    (12/2/94) Created this file.
  12.  *
  13.  *----------------------------------------------------------------------------*/
  14.  
  15. #include <Types.h>
  16. #include <Resources.h>
  17. #include "ActionAtomIntf.h"
  18. #include "AtomUtils.h"
  19.  
  20. pascal long    SETFOLDERICON(AAPBRecPtr myAAPBPtr)
  21. {
  22.     OSErr        err;
  23.     intfHdl        resH;
  24.     CInfoPBRec    info;
  25.     DInfo        *myDirInfo;
  26.     Str255        pathStorage;
  27.     long        theDirID;
  28.     
  29.     if (myAAPBPtr->whichStage == after) 
  30.     {
  31.         resH = (intfHdl)Get1Resource('intf', myAAPBPtr->aaRefCon);
  32.         if (resH) {
  33.             HLock( (Handle)resH );
  34.             if (StripFileName((*resH)->pathName) == noErr)
  35.             {
  36.                 if ( (*resH)->pathName[1] != ':' )                    //    Found SpecialFolder
  37.                 {
  38.                     theDirID = DirIDFromSpecialPath( (*resH)->pathName, myAAPBPtr->targetVRefNum );
  39.                     PathFromSpecialPath( pathStorage, (*resH)->pathName );
  40.                 }
  41.                 else
  42.                 {
  43.                     // This was a target pathname like ':Folder 1:FileName', no chopping necessary
  44.             
  45.                     BlockMove(&((**resH).pathName), pathStorage, (**resH).pathName[0] + 1);
  46.             
  47.                     // The target was off of the root, not the blessed, so adjust the dirID we'll look for the file
  48.                     // to the root of the target volume.
  49.             
  50.                     theDirID = 0;
  51.                 }
  52.  
  53.                 info.dirInfo.ioCompletion = nil;
  54.                 info.dirInfo.ioVRefNum = myAAPBPtr->targetVRefNum;
  55.                 info.dirInfo.ioNamePtr = pathStorage;
  56.                 info.dirInfo.ioFDirIndex = 0;
  57.                 info.dirInfo.ioDrDirID = theDirID;
  58.                 
  59.                 if (PBGetCatInfo(&info, false) == noErr) {
  60.                     myDirInfo = &info.dirInfo.ioDrUsrWds;
  61.                     myDirInfo->frFlags &= 0xFEFF;    
  62.                                 // clear the init'd bit
  63.                     myDirInfo->frFlags |= 0x0400;    
  64.                                 // set the "Use Custom Folder Icon" bit
  65.                                 
  66.                                 // now that the ioDrDirID field is filled in corectly
  67.                                 // let's use it to identify the directory instead of the name ptr.
  68.                     info.dirInfo.ioNamePtr = nil;
  69.                     info.dirInfo.ioFDirIndex = -1;
  70.                     err = PBSetCatInfo(&info,false);
  71.                 }
  72.             }
  73.             HUnlock((Handle)resH);
  74.             ReleaseResource((Handle)resH);
  75.         }
  76.     }        
  77.     return err; // Since the installation reached this point, dont abort 
  78. }
  79.  
  80.  
  81.  
  82.